%matplotlib inline
import numpy as np
from scipy import misc
import matplotlib.pyplot as plt
import imageio
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
type(photo_data)
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
photo_data.shape
photo_data.size
photo_data[150,250]
photo_data[200:800, :, 1] = 255
plt.figure(figsize=(10,10))
plt.imshow(photo_data)
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
photo_data[200:800, :] = 255
plt.figure(figsize=(10,10))
plt.imshow(photo_data)
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
print("Shape of photo-data:", photo_data.shape)
low_value_filter = photo_data < 200
print("Shahpe of low_value_filter:",low_value_filter.shape)
import random
plt.figure(figsize=(10,10))
plt.imshow(photo_data)
photo_data[low_value_filter] = 0
plt.figure(figsize=(10,10))
plt.imshow(photo_data)
total_rows, total_cols, total_layers = photo_data.shape
X, Y = np.ogrid[:total_rows, :total_cols]
print("X= ",X.shape, "and Y = ", Y.shape)
center_row, center_col = total_rows/2, total_cols/2
dist_center = (X - center_row)**2 + (Y - center_col)**2
#print(dist_center)
radius = (total_rows / 2)**2
#print(radius)
circ_mark = (dist_center > radius)
#print(circ_mark)
#print(circ_mark[1500:1700,2000:2200])
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
photo_data[circ_mark] = 0
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
X, Y = np.ogrid[:total_rows, :total_cols]
half_upper = X < center_row
half_upper_mask = np.logical_and(half_upper, circ_mark)
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
photo_data[half_upper_mask] = 255
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
red_mask = photo_data[:, : ,0] < 150
photo_data[red_mask] = 0
plt.figure(figsize=(15,15))
plt.imshow(photo_data)